package servlet;

import dao.CourseDao;
import vo.Course;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

/**
 * Created by ssw on 2018/6/12.
 */
public class AskCourseServlet extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        CourseDao courseDao =new CourseDao();
        List<Course> courseList= courseDao.askCourseList();
        HttpSession session=req.getSession();
        req.setAttribute("courseList", courseList);
        if(req.getParameter("from")!=null&&req.getParameter("from").equals("admin_addsc"))
            req.getRequestDispatcher("sgms/admin_addsc.jsp").forward(req, resp);
        else if(req.getParameter("from")!=null&&req.getParameter("from").equals("seeCourses"))
            req.getRequestDispatcher("sgms/admin_seeCouses.jsp").forward(req, resp);
        else
            req.getRequestDispatcher("sgms/admin_addCourse.jsp").forward(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        this.doGet(req, resp);
    }
}
